package com.ochnas.volunteersignup.service;

import java.util.ArrayList;
import java.util.List;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

public class JmsMessageListener implements MessageListener {

	 public final List messages = new ArrayList();
	 
	@Override
	public void onMessage(Message message) {
		messages.add(message);
		
//		TextMessage notifyPositionSignupMessage = null;
//		try {
//			// check the message type is text format
//			if (message instanceof TextMessage) {
//				notifyPositionSignupMessage = (TextMessage) message;
//				
//				System.out.print("Message received from the POSITION_TOPIC: ");
//				System.out.println(notifyPositionSignupMessage.getText());
//			} else {
//				System.out.println("Message of wrong type: ");
//				System.out.println(message.getClass().getName());
//			}
//			// throw the Exception if there are internal errors
//		} catch (JMSException jmsEx) {
//			System.out.println("Exception in onMessage(): ");
//			System.out.println(jmsEx.toString());
//		} catch (Throwable jmsTh) {
//			System.out.print("Exception in onMessage(): ");
//			System.out.println(jmsTh.getMessage());
//		} // end of try
	} // end of onMessage() method
} // end of JmsMessageListener class
